#ifndef LOG_DEBUG_H
#define LOG_DEBUG_H
#include <stdio.h>
#include <stdarg.h>
int log_printf(const char *format, ...);
enum{
    LOG_LEVEL_OFF = 0,
    LOG_LEVEL_ERROR = 1,
    LOG_LEVEL_WARN = 2,
    LOG_LEVEL_INFO = 3,
    LOG_LEVEL_DEBUG = 4,
    LOG_LEVEL_VERBOSE = 5,
    LOG_LEVEL_VERBOSE_VEBOSE = 6
};

#define DEFAULT_LOG_LEVEL LOG_LEVEL_VERBOSE_VEBOSE


#ifndef LOG_TAG
#define _LOG_TAG "[Unknown]"
#else
#define _LOG_TAG LOG_TAG
#endif

#ifndef LOG_LEVEL
#define _LOG_LEVEL DEFAULT_LOG_LEVEL
#else
#define _LOG_LEVEL LOG_LEVEL
#endif

#define LOGE(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_ERROR){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#define LOGW(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_WARN){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#define LOGI(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_INFO){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#define LOGD(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_DEBUG){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#define LOGV(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_VERBOSE){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#define LOGV_V(format, ...) \
do{ \
    if(_LOG_LEVEL >= LOG_LEVEL_VERBOSE_VEBOSE){ \
        log_printf(_LOG_TAG format "\r\n", ##__VA_ARGS__); \
    }\
}while(0);

#endif
